/**
 * Entity extends
 * @author hoang.pt
 * @version $Id: MethodInfo.java 103 2010-08-28 15:52:20Z phantichhoang $
 */

package workshop.workshop1;

/**
 * Use getName() and setName() API for thread
 * @author hoang.pt
 */
public class MethodInfo extends Thread {

    /**
     * constructor
     * @param String n
     */
    public MethodInfo(String n) {
        this.setName(n);
    }

    /**
     * Override method print the method of lecture
     * @author hoang.pt
     */
    @Override
    public void run() {
        //super.run();
        System.out.println("\nHello!!!");
        System.out.println("My name is: " + this.getName() + "\n");
        System.out.println("Today, I am going to tell you in brief about some of the methods used in Thread class.\n");

        String slide[] = {
            "The getName() method helps to retrieve the name of the current thread.",
            "The start() method allocates the system resources necessary to run the thread and executes the run() method of its target object.",
            "The life of a thread starts when the run() method is invoked.",
            "The sleep() method suspends the execution of the current thread for a specified period of time.",
            "The interrupt() method tells the thread to stop what it was doing before it has completed the task."
        };

        //print slide
        for(int i = 0; i < slide.length; i++) {
            //pause 1000ms each line of slide
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }

            // Display the message
            System.out.println(slide[i]);
        }

        try {
            Thread.sleep(4000);
            System.out.println("\nThank you for joining.");
        } catch(InterruptedException e) {
            e.printStackTrace();
        }

    }


}
